#include <iostream>

#include <cstdint>
#include <string>

enum Type {
    Bool,
    Int8,
    Int16,
    Int32,
    Int64,
    Uint8,
    Uint16,
    Uint32,
    Uint64,
    Float,
    Double,
    String
};

class TypeWriter {
public:
    TypeWriter(char * buf, size_t len):_buf(buf), _len(len) {}
    ~TypeWriter(){}

    TypeWriter & append(int8_t v){ return *this;}
    TypeWriter & append(int16_t v){ return *this;}
    TypeWriter & append(int32_t v){ return *this;}
    TypeWriter & append(int64_t v){ return *this;}

    TypeWriter & append(uint8_t v){ return *this;}
    TypeWriter & append(uint16_t v){ return *this;}
    TypeWriter & append(uint32_t v){ return *this;}
    TypeWriter & append(uint64_t v){ return *this;}

    TypeWriter & append(float v){ return *this;}
    TypeWriter & append(double v){ return *this;}

    TypeWriter & append(const char * cstr){ return *this;}
    TypeWriter & append(const char * buf,  size_t len){ return *this;}
    TypeWriter & append(const std::string & v){ return *this;}
private:
    char * _buf;
    size_t _len;
};
class TypeReader {
public:
    Type type();
    bool getInt8 (const char * buf, size_t len, int8_t & v)     const { return true; }
    bool getInt16(const char * buf, size_t len, int16_t & v)    const { return true;}
    bool getInt32(const char * buf, size_t len, int32_t & v)    const { return true;}
    bool getInt64(const char * buf, size_t len, int64_t & v)    const { return true;}

    bool getUint8 (const char * buf, size_t len, uint8_t & v)   const { return true;}
    bool getUint16(const char * buf, size_t len, uint16_t & v)  const { return true;}
    bool getUint32(const char * buf, size_t len, uint32_t & v)  const { return true;}
    bool getUint64(const char * buf, size_t len, uint64_t & v)  const { return true;}

    bool getFloat(const char * buf, size_t len, float & v)  const { return true;}
    bool getDouble(const char * buf, size_t len, double & v)const { return true;}

    bool getString(const char * buf, size_t len, std::string & v) const {return true ;}
    bool getString(const char * buf, size_t len, char * v, size_t vLen ) const {return true ;}
};

void test_TypeWriter(){
    char buf[128] = {0};
    
    auto * appender = new TypeWriter(buf, sizeof(buf));
    appender->append((int8_t)32).append((int16_t)32).append((int32_t)32).append((int64_t)32);
    appender->append((uint8_t)32).append((uint16_t)32).append((uint32_t)32).append((uint64_t)32);

    appender->append(std::string("helloworld")).append("hello", 5);

    appender->append((float)12.8).append((double)12.9);
    
    delete appender;
}

int main(){
    test_TypeWriter();
    return 0;
}




